<template>
  <div class="lowpriceContent">
    <div class="lowpriceNavBar">
      <van-nav-bar title="特价促销" :border="false"></van-nav-bar>
    </div>
    <div class="lowpriceSwiper">
      <van-swipe @change="onChange" autoplay="3000">
        <van-swipe-item v-for="(swiper,i) in swiper" :key="i">
          <img :src="swiper.pic" />
        </van-swipe-item>
        <template #indicator>
          <div class="custom-indicator">{{ current + 1 }}/{{swiper.length}}</div>
        </template>
      </van-swipe>
    </div>
    <div class="addGoods">
      <addGoods :addGoods="addGoods"></addGoods>
    </div>
  </div>
</template>

<script>
import addGoods from "../../components/addGoods";
import { shoppingService } from "@/api";
export default {
  name: "lowprice",
  data() {
    return {
      current: 0,
      swiper: [],
      addGoods: [],
    };
  },
  created(){
    this.asgetSlideAdvers();
    this.asgetspecialList();
  },
  methods: {
    // 轮播图
    onChange(index) {
      this.current = index;
    },
    // 获取广告列表
    async asgetSlideAdvers() {
      const { data } = await shoppingService.getSlideAdvers(7);
      console.log(data, "轮播图");
      this.swiper = data; 
    },
    // 商品特价列表
    async asgetspecialList(){
      const { data } = await shoppingService.getspecialList(1,4,3,0,1);
      console.log(data,"特价列表")
      this.addGoods = data.list
    },
  },
  components: {
    addGoods
  }
};
</script>

<style scoped>
.lowpriceContent {
  background-color: rgba(247, 249, 252, 1);
}
.lowpriceSwiper {
  margin-top: 15px;
  width: 100%;
  text-align: center;
}
.lowpriceSwiper img {
  width: 95%;
  height: 155px;
}
.custom-indicator {
  position: absolute;
  right: 15px;
  bottom: 15px;
  padding: 2px 5px;
  font-size: 15px;
  background-color: #69413e;
  color: #fff;
  border-radius: 20px;
}
</style>
